/**
 * Created by CK on 2017/3/14.
 */
var list,
    form,
    taskType = xhTool.getQuery('iTaskType');
$(document).ready(function(){
    var userId        = xhTool.getQuery('userId'),
        queryParams   = {taskType: taskType,userId:userId},
        isAdd         = xhTool.getQuery('isAdd'),
        startDom      = $('#List_Search_StartDate'),
        endDom        = $('#List_Search_EndDate'),
        schoolIdDom   = $('#List_Search_SchoolId'),
        reportDom   = $('#iReportUserId'),
        vagueDom      = $('#list_search'),
        stateIdDom    = $('#List_Search_State'),
        appNameDom    = $('#List_Search_AppName'),
        creatorDom    = $('#List_Search_CreatorName'),
        // appPackageDom = $('#List_Search_AppPackage'),
        confStateDom  = $('#List_Search_ConfirmState'),
        schoolId      = xhTool.getQuery('schoolId'),
        proNameDom    = $('#proType');

    //var schoolNameDom = $('#List_Search_SchoolName');
    //var appPackageDom = $('#List_Search_AppPackage');
    list = $('#List');
    form = new xhForm($("#xh_form"));
    form.parse().bindRequired($('#bt_form_add, #bt_form_edit'));
    $('.xh-datagrid-toolbar').parseToolbar();
    // $('.xh-form').parseForm($('#bt_form_add, #bt_form_edit'));
    if (taskType ==2) {
        list.initDataGrid(baseUrl + 'Track/getProTrackTaskData', {"queryParams": queryParams}).setSelectThenEnable([], ['bt_list_SchoolConfirm','bt_list_Log', 'bt_list_del']);
    } else {
        list.initDataGrid(baseUrl + 'Track/getTrackTaskData', {"queryParams": queryParams}).setSelectThenEnable([], ['bt_list_SchoolConfirm','bt_list_Log', 'bt_list_del']);
    }

    var stateColor = {
        '新建': '#ffb4b4',
        // 开发进行中: '#99FFCC',
        '开发中': '#99FFCC',
        // 学校待确认: '#ffff99',
        '已发布': '#ffff99'
    };
    if(list.datagrid("getRows").length>0){
        DataGrid.rowStyler = function(rowIndex, rowData){
            if (stateColor[rowData.iState.split('(')[0]]){
                $('tr[datagrid-row-index="'+ rowIndex +'"]').find('td[field="ck"]').css('background-color', stateColor[rowData.iState.split('(')[0]]);
                //return 'background-color:'+ stateColor[rowData.iState] +';';
            }
        };
    }

    $('#List_Search_AppName').combobox({
        editable:true,
        multiple:true,
        setValue:0,
        onChange: function (newValue, oldValue) {
            var newIndex = newValue.indexOf('0');
            var oldIndex = oldValue.indexOf('0');
            if (newValue.length>1&&newIndex>=0&&oldIndex>=0) {
                newValue.splice(newIndex, 1);
            }
            if (oldIndex<0&&newIndex>=0) {
                newValue = [0];
            }
            $('#List_Search_AppName').combobox('setValues',newValue);
        }

    });

    $('#List_Search_CreatorName').combobox({
        editable:true,
        multiple:true,
        setValue:0,
        onChange: function (newValue, oldValue) {
            var newIndex = newValue.indexOf('0');
            var oldIndex = oldValue.indexOf('0');
            if (newValue.length>1&&newIndex>=0&&oldIndex>=0) {
                newValue.splice(newIndex, 1);
            }
            if (oldIndex<0&&newIndex>=0) {
                newValue = [0];
            }
            $('#List_Search_CreatorName').combobox('setValues',newValue);
        }
    });


    $('#proType').combobox({
        editable:true,
        multiple:true
    });

    //翻页不记录原ID
    DataGrid.onLoadSuccess = function() {
        list.dataGridClear();
    };

    var stateDom = $('#div_state');
    var support_state = $('#support_state');
    if (taskType != 2) {
        stateDom.append('<div onclick = "setTaskState(0)"><a>新建</a></div>');
        $.each(useful.stateArr, function(id, name){
            stateDom.append('<div onclick = "setTaskState('+ id +')"><a>'+ name +'</a></div>');
        });
    } else {
        $.each(useful.stateArr, function(id, name){
            stateDom.append('<div onclick = "setTaskState('+ id +')"><a>'+ name +'</a></div>');
        });
        $.each(useful.suppState, function(id, name){
            support_state.append('<div onclick = "setSuppTaskState('+ id +')"><a>'+ name +'</a></div>');
        });
    }
    if (taskType != 2) {
        $('#bt_list_SetState').menubutton({
            menu: '#div_state'
        });
    } else {
        $('#bt_list_TechState').menubutton({
            menu: '#div_state'
        });
        $('#bt_list_SuppState').menubutton({
            menu: '#support_state'
        });
        $('#bt_list_assign').menubutton({
            menu: '#assign',
        });
    }


    var appPackDom = $('#XHTrack_Task_sAppPackage');
    if(appPackDom.length > 0) {
        var appArr = [{id:'', text:''}];
        $.each(useful.appArr, function(id, value){
            appArr.push({id: id, text: value});
        });
        appPackDom.select2({
            placeholder: '选择产品',
            data: appArr
        });
    }

    //问题分类查询
    var proType = $('#proType');
    if(taskType==2){
        if(proType.length > 0){
            proType.combotree({
                multiple:true,
                valueField:'id',
                textField:'text',
                url:'getSearchEnum',
                width:120
            });
        }
    }

    //问题分类
    var proStyle = $('#sProblemStyle');
    if (taskType == 2) {
        if(proStyle.length > 0){
            proStyle.combotree({
                valueField:'id',
                textField:'text',
                editable:true,
                url:'getSearchEnum',
                // width:400
            });
        }
    } else {
        if (proStyle.length > 0) {
            $('#sProblemStyle').parent().parent().hide();
        }
    }
    //上报人
    var iReportUserId = $('#iReportUserId');
    if(taskType==2){
        if(iReportUserId.length > 0){
            iReportUserId.combobox({
                valueField:'id',
                textField:'text',
                url:'getReportUserId',
                editable:true,
                // width:400,
            });
        }
    }else{
        if(iReportUserId.length > 0){
            $('#iReportUserId').parent().parent().hide();
        }
    }
    if(taskType!=2){
        $('#iProLevel').parent().parent().hide();
    }

    var schoolArr = [];
    $.each(useful.schoolArr, function(id, name){
        schoolArr.push({id: id, text: name});
    });
    $('#XHTrack_Task_sSchoolId').select2({
        placeholder: '选择学校',
        data: schoolArr,
        allowClear: true
    });
    $('#bt_list_SchoolConfirm').click(function(){
        if($(this).checkButtonDisabled()) return false;
        var id = list.getDataGridSelectedField('iTTId');
        var src = baseUrl + 'Track/schoolTaskConfirm?iTTId=' + id;
        window.top.xhTop.showModal({
            title: '学校确认',
            content: '<iframe style="width: 100%;height:400px;" frameborder="0" src="' + src + '"></iframe>',
            button: '确认'
        });
    });

    $('#moveTask').click(function () {
        var id = list.getDataGridSelectedField('iTTId');
        if (!id) {
            window.top.xhTop.showError('请选择要操作的记录！');
            return false;
        }
        window.top.xhTop.showModal({
            title: '组内指派',
            width: 770,
            content: '<iframe src="' + baseUrl + 'track/assignTask?iType=2&iTTId=' + id +'"  style="width: 100%;border-style: none;padding: 0px;height: 400px"  scrolling="yes"></iframe>',
            button: '提交',
            backClose: false
        });
    });

    $('#assignTask').click(function () {
        var id = list.getDataGridSelectedField('iTTId');
        if (!id) {
            window.top.xhTop.showError('请选择要操作的记录！');
            return false;
        }
        window.top.xhTop.showModal({
            title: '技术指派',
            width: 770,
            content: '<iframe src="' + baseUrl + 'track/assignTask?iType=1&iTTId=' + id +'"  style="width: 100%;border-style: none;padding: 0px;height: 400px"  scrolling="yes"></iframe>',
            button: '提交',
            backClose: false
        });
    });

    DataGrid.onDblClickCell = function(rowIndex, field, value){
        var rowData = list.datagrid('getRows');
        list.datagrid('selectRow',rowIndex);
        rowData = rowData[rowIndex];
        if(field == 'iState' || field == 'iConfirmState'){
            var src = baseUrl + 'Track/stateChangeLog?taskId=' + rowData.iTTId;
            var option = {
                title: '状态改变记录',
                content: '<iframe frameborder="0" style="width: 100%;height: 500px;" src="'+ src +'"></iframe>',
                size: 'md'
            };
            if($('#bt_form_edit')){
                option.button = '确定';
            }
            window.top.xhTop.showModal(option);
            return false;
        }
        else{
            // $.post(baseUrl + 'Track/getTaskInfo', {id: rowData.iTTId}, function(data){
            //     $.overtFun.clickAddList();
            //     $('#bt_form_add, #bt_form_reset').hide();
            //     $('#bt_form_edit').show();
            //     form.fill(data);
            //     // $("#xh_form").xhForm('fillData', data);
            //     appPackDom.trigger('change').prop("disabled", true);
            //     proStyle.combotree('setValue',data.iProblemStyle);
            //     iReportUserId.combobox('setValue',data.iReportUserId);
            //     $('#XHTrack_Task_sSchoolId').val(data.sSchoolId ? data.sSchoolId.split(',') : '').trigger('change');//.prop("disabled", true);
            //     $('#XHTrack_Task_sTaskName').change();
            //     //超级管理员可修改应用
            //     if(userType == 8){
            //         appPackDom.prop("disabled", false);
            //     }
            //     um.setContent(data.sTaskContent);
            // }, 'json');
            if (taskType == 2) {
                var title = '编辑问题';
            } else if (taskType == 1) {
                var title = '编辑需求';
            }
            window.top.xhTop.createNewTab(title, 'track/trackTaskForm?iType=' + taskType+'&iTTId='+rowData.iTTId, true);
            return false;
        }
    };

    /** 列表 **/
    $('#bt_list_add').click(function(){
        // $.overtFun.clickAddList();
        // $('#XHTrack_Task_sAppPackage').trigger('change').prop("disabled", false);
        // $('#XHTrack_Task_sSchoolId').val(null).trigger('change');//.prop("disabled", false);
        // $('#XHTrack_Task_iTaskType').val(taskType);
        // proStyle.combotree('clear');
        // iReportUserId.combobox('clear');
        //
        // if(userId != null){
        //     $('#XHTrack_Task_sSchoolId').val(schoolId).trigger('change');
        //     setOfferInfo(userId+',','aa');
        //     $('#XHTrack_Task_sOfferIds,#XHTrack_Task_sSchoolId').parent().parent().hide();
        // }
        // um.execCommand('cleardoc');
        var title = '新增任务';
        window.top.xhTop.createNewTab(title, 'track/trackTaskForm?iType=' + taskType, true);
        return false;
    });

    var btSearchDom = $('#bt_list_search');
    btSearchDom.click(function(){
        queryParams.startDate   = startDom.getElementValue();
        queryParams.endDate     = endDom.getElementValue();
        queryParams.schoolId    = schoolIdDom.getElementValue();
        queryParams.iReportUserId    = reportDom.getElementValue();
        queryParams.vague       = vagueDom.getElementValue();
        queryParams.state       = stateIdDom.getElementValue();
        queryParams.iProductId   = xhExtra.getValue(appNameDom);
        queryParams.proName   = xhExtra.getValue(proNameDom);
        queryParams.confirmState= confStateDom.getElementValue();
        queryParams.creatorId= xhExtra.getValue(creatorDom);

        //queryParams.schoolName= schoolNameDom.getElementValue();
        // queryParams.appPackage= appPackageDom.getElementValue();
        list.addDataGridParams(queryParams);
    });
    xhTool.bindDocKeyDown(btSearchDom);

    //导出excel
    var btExportDom = $('#bt_list_export');
    btExportDom.click(function () {
        queryParams.startDate   = startDom.getElementValue();
        queryParams.endDate     = endDom.getElementValue();
        queryParams.schoolId    = schoolIdDom.getElementValue();
        queryParams.iReportUserId    = reportDom.getElementValue();
        queryParams.vague       = vagueDom.getElementValue();
        queryParams.state       = stateIdDom.getElementValue();
        queryParams.iProductId   = xhExtra.getValue(appNameDom);
        queryParams.proName   = xhExtra.getValue(proNameDom);
        queryParams.confirmState= confStateDom.getElementValue();
        queryParams.creatorId= xhExtra.getValue(creatorDom);
        location.href = baseUrl + 'track/exportProblemData?'+ xhTool.parseParam(queryParams);
    });
    $('#bt_list_del').click(function () {
        var id = list.getDataGridSelectedField('iTTId');
        $.overtFun.clickDelList(id, baseUrl + 'Track/delTaskRecord');
    });

    /** 表单 **/
    $('#bt_form_add').click(function(){
        $.overtFun.clickSubmitForm();
    });
    $('#bt_form_edit').click(function(){
        $.overtFun.clickSubmitForm();
        // $('#xh_form').submit();
        // $('.xh-form').hide();
        // $('.xh-datagrid').parent().fadeIn();
        // $('body').css('overflow-y', 'hidden');
        // $('#List').datagrid('reload');
        // $('#xh_form').submit();
        // $('.xh-form').hide();
        // $('.xh-datagrid').parent().fadeIn();
        // $('body').css('overflow-y', 'hidden');
        // $('#List').datagrid('reload');
    });

    //表单返回按钮
    $('#bt_form_back').click(function(){
        $.overtFun.clickBackForm();
    });
    $('#bt_form_reset').click(function(){
        $.overtFun.clickResetForm();
    });


    // if(taskType ==2){
    //     var um = UE.getEditor('XHTrack_Problem_sTaskContent', {
    //         autoHeightEnabled: true,
    //         serverUrl: baseUrl + 'Track/uploadImage',
    //         textarea: 'XHTrack_Problem_sTaskContent',
    //         initialFrameWidth: '100%',
    //         imageScaleEnabled: false,
    //         toolbars: [[
    //             'source', '| ', 'undo', 'redo', '|', 'bold', 'italic', 'underline', 'strikethrough', '|', 'superscript', 'subscript', '|',
    //             'forecolor', 'backcolor', '|', 'removeformat',
    //             '|', 'insertorderedlist', 'insertunorderedlist', '|', 'selectall', 'cleardoc', 'paragraph' ,
    //             '|', 'justifyleft', 'justifycenter', 'justifyright',
    //             '|', 'insertimage', 'insertvideo', 'link', 'unlink',
    //             '|', 'horizontal', 'preview ',
    //         ]],
    //
    //         /* 上传图片配置项 */
    //         "imageActionName": "uploadImage", /* 执行上传图片的action名称 */
    //         "imageFieldName": "upfile", /* 提交的图片表单名称 */
    //         "imageMaxSize": 2048000, /* 上传大小限制，单位B */
    //         "imageAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], /* 上传图片格式显示 */
    //         "imageCompressEnable": true, /* 是否压缩图片,默认是true */
    //         "imageCompressBorder": 1600, /* 图片压缩最长边限制 */
    //         "imageInsertAlign": "none", /* 插入的图片浮动方式 */
    //         "imageUrlPrefix": "", /* 图片访问路径前缀 */
    //         "imagePathFormat": "",
    //
    //         /* 上传视频配置 */
    //         "videoActionName": "uploadImage", /* 执行上传视频的action名称 */
    //         "videoFieldName": "upfile", /* 提交的视频表单名称 */
    //         "videoPathFormat": "", /* 上传保存路径,可以自定义保存路径和文件名格式 */
    //         "videoUrlPrefix": "", /* 视频访问路径前缀 */
    //         "videoMaxSize": 102400000, /* 上传大小限制，单位B，默认100MB */
    //         "videoAllowFiles": [
    //             ".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
    //             ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid"], /* 上传视频格式显示 */
    //
    //     });
    // } else {
    //     var um = UM.getEditor('XHTrack_Task_sTaskContent', {
    //         autoHeightEnabled: true,
    //         imageUrl: baseUrl + 'Track/uploadImage',
    //         imagePath : '',
    //         textarea: 'XHTrack_Task_sTaskContent',
    //         imageScaleEnabled: false,
    //         dropFileEnabled: true,
    //         initialFrameWidth: '100%',
    //         toolbar: [
    //             'source | undo redo | bold italic underline strikethrough | superscript subscript | forecolor backcolor | removeformat',
    //             '| insertorderedlist insertunorderedlist | selectall cleardoc paragraph' ,
    //             '| justifyleft justifycenter justifyright ',
    //             '| image video  link unlink',
    //             '| horizontal preview ',
    //             '| formula'
    //         ]
    //     });
    // }








    if (isAdd) {
        $('#bt_list_add').click();
    }

    if (!useful.isTech && taskType !== '3') {
        $('#XHTrack_Task_sSolveVersion').parent().parent()
            .add($('#XHTrack_Task_tPlanFinishTime').parent().parent())
            .hide();
    }

    $('#XHTrack_Task_sOfferUserName').click(function () {
        var schoolIds = $('#XHTrack_Task_sSchoolId').val();
        if (!schoolIds) {
            window.top.xhTop.showError('请先选择学校！');
            return false;
        }
        window.top.xhTop.showModal({
            title: '选择提问人',
            content: xhTool.getFrameString('Track/schoolOffer', {schoolIds: schoolIds.join(',')}, 400),
            button: '确认'
        });
    });

    //查看负责人变更记录
    $('#bt_list_Log').click(function () {
        if($(this).checkButtonDisabled()) return false;
        var id = list.getDataGridSelectedField('iTTId');
        var src = baseUrl + 'Track/stateChangeLog?taskId=' + id;
        var option = {
            title: '状态改变记录',
            content: '<iframe frameborder="0" style="width: 100%;height: 500px;" src="'+ src +'"></iframe>',
            size: 'md'
        };
        window.top.xhTop.showModal(option);
        return false;

    });

});
function setTaskState(stateId){
    var ids = list.getDataGridSelectedFields('iTTId');
    if(!ids){
        window.top.xhTop.showMessage({
            title: '无选中记录，无法操作！',
            type: 'error'
        });
        return false;
    }
    if (taskType == 2) {
        var url = 'Track/setProTaskState';
    } else {
        var url = 'Track/setTaskState';
    }
    if (stateId === 99 && taskType !== '3') {
        window.top.swal({
            showCancelButton: true,
            confirmButtonText: '确认',
            cancelButtonText: '取消',
            showLoaderOnConfirm: true,
            allowOutsideClick: false,
            title: '请输入解决版本',
            input: 'text',
            preConfirm: function(solveVersion) {
                return new Promise(function (resolve, reject) {
                    if(!solveVersion){
                        reject('版本不能为空！');
                    }
                    else {
                        xhExtra.ajaxRequest(
                            url,
                            {ids: ids, state: stateId, taskType: taskType, solveVersion: solveVersion},
                            {success: true}
                        );
                        list.dataGridReload();
                        resolve();
                    }
                })
            }
        });
    } else if ($.inArray(stateId, [30, 40, 50]) >= 0) {
        if (stateId == 50) {
            var html = "<input type='text' onfocus='this.type ="+'"date"'+"' id='plan_date' class='swal2-input' placeholder='计划发版时间' />"+
                '<input id="explain" class="swal2-input" placeholder="说明" >';
        } else {
            var html = "<input type='text' onfocus='this.type ="+'"date"'+"' id='plan_date' class='swal2-input' placeholder='计划完成日期' />"+
                '<input id="explain" class="swal2-input" placeholder="说明" >';
        }
        window.top.swal({
            showCancelButton: true,
            confirmButtonText: '确认',
            cancelButtonText: '取消',
            showLoaderOnConfirm: true,
            allowOutsideClick: false,
            title: '请输入相关信息',
            html:html,
            preConfirm: function() {
                return new Promise(function (resolve, reject) {
                    var planDate = $('#plan_date', window.top.document).val(),
                        explain  = $('#explain', window.top.document).val();
                    if(!planDate || !explain){
                        reject('信息不能为空！');
                    }
                    else if(explain.length > 250) {
                        reject('说明文字超长！');
                    }
                    else {
                        xhExtra.ajaxRequest(
                            url,
                            {ids: ids, state: stateId, taskType: taskType, planDate: planDate, explain: explain},
                            {success: true}
                        );
                        list.dataGridReload();
                        resolve();
                    }
                })
            }
        });
    }else if (stateId == 33 || stateId == 37){ //暂停 未定位
        var html =  '<textarea type="text" id="reason" class="swal2-textarea" placeholder="原因" name="reason" rows = "3" cols = "100"></textarea>' +
                '<input id="explain" class="swal2-input" placeholder="说明" >';
        window.top.swal({
            showCancelButton: true,
            confirmButtonText: '确认',
            cancelButtonText: '取消',
            showLoaderOnConfirm: true,
            allowOutsideClick: false,
            title: '请输入相关信息',
            html:html,
            preConfirm: function() {
                return new Promise(function (resolve, reject) {
                    var reason = $('#reason', window.top.document).val(),
                        explain  = $('#explain', window.top.document).val();
                    if(!reason || !explain){
                        reject('暂停原因不能为空！');
                    }
                    else if(explain.length > 250) {
                        reject('说明文字超长！');
                    }
                    else {
                        xhExtra.ajaxRequest(
                            url,
                            {ids: ids, state: stateId, taskType: taskType, reason: reason, explain: explain},
                            {success: true}
                        );
                        list.dataGridReload();
                        resolve();
                    }
                })
            }
        });
    }
    else if(stateId == 38){ //已定位
        var html =  '<textarea type="text" id="reason" class="swal2-textarea" placeholder="原因" name="reason" rows = "3" cols = "100"></textarea>' +
            '<input id="sSolveWay" class="swal2-input" placeholder="解决方法" >'+
            "<input type='text' onfocus='this.type ="+'"date"'+"' id='plan_date' class='swal2-input' placeholder='计划完成时间' />"+
            '<input id="explain" class="swal2-input" placeholder="说明" >';
        window.top.swal({
            showCancelButton: true,
            confirmButtonText: '确认',
            cancelButtonText: '取消',
            showLoaderOnConfirm: true,
            allowOutsideClick: false,
            title: '请输入相关信息',
            html:html,
            preConfirm: function() {
                return new Promise(function (resolve, reject) {
                    var reason = $('#reason', window.top.document).val();
                    var sSolveWay = $('#sSolveWay', window.top.document).val();
                    var planDate = $('#plan_date', window.top.document).val();
                    var explain  = $('#explain', window.top.document).val();
                    if(!reason){
                        reject('暂停原因不能为空！');
                    }
                    else if(!sSolveWay){
                        reject('解决方法不能为空！');
                    }
                    else if(explain.length > 250) {
                        reject('说明文字超长！');
                    }
                    else {
                        xhExtra.ajaxRequest(
                            url,
                            {ids: ids, state: stateId, taskType: taskType, planDate: planDate, explain: explain, reason: reason, sSolveWay: sSolveWay},
                            {success: true}
                        );
                        list.dataGridReload();
                        resolve();
                    }
                })
            }
        });
    }
    else {
        window.top.swal({
            showCancelButton: true,
            confirmButtonText: '确认',
            cancelButtonText: '取消',
            showLoaderOnConfirm: true,
            allowOutsideClick: false,
            title: '输入说明',
            input: 'text',
            preConfirm: function(explain) {
                return new Promise(function (resolve, reject) {
                    if(!explain){
                        reject('说明不能为空！');
                    }
                    else if(explain.length > 250) {
                        reject('说明文字超长！');
                    }
                    else {
                        xhExtra.ajaxRequest(
                            url,
                            {ids: ids, state: stateId, taskType: taskType, explain: explain},
                            {success: true}
                        );
                        list.dataGridReload();
                        resolve();
                    }
                })
            }
        });
    }
    // $.post(baseUrl + 'Track/setTaskState', {ids: ids, state: stateId, taskType: taskType}, function(result){
    //     if(result == 'success'){
    //         window.top.xhTop.showMessage({
    //             title: '更新成功！',
    //             type: 'success'
    //         });
    //         list.dataGridReload();
    //         return false;
    //     }
    //     window.top.xhTop.showMessage({
    //         title: result,
    //         type: 'error'
    //     });
    // });
}

function setSuppTaskState(stateId) {
    var ids = list.getDataGridSelectedFields('iTTId');
    if(!ids){
        window.top.xhTop.showMessage({
            title: '无选中记录，无法操作！',
            type: 'error'
        });
        return false;
    }
    window.top.swal({
        showCancelButton: true,
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        showLoaderOnConfirm: true,
        allowOutsideClick: false,
        title: '输入说明',
        input: 'text',
        preConfirm: function(explain) {
            return new Promise(function (resolve, reject) {
                if(!explain){
                    reject('说明不能为空！');
                } else {
                    xhExtra.ajaxRequest(
                        'Track/setSuppTaskState',
                        {ids: ids, state: stateId, taskType: taskType, explain: explain},
                        {success: true}
                    );
                    list.dataGridReload();
                    resolve();
                }
            })
        }
    });

}

function setOfferInfo(idStr, nameStr) {
    $('#XHTrack_Task_sOfferIds').val(idStr);
    $('#XHTrack_Task_sOfferUserName').val(nameStr).trigger('change');
}